import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from './router'
import store from './store'
// 引入icon图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 引入封装好的全局组件
import gCom from './common'
// 引入封装好的类型转化函数
import { isKey } from '@/util/common'
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

//循环创建全局组件
for (let i in gCom) {
    //先判断 如果未转化  报错
    // console.log(isKey(i, gCom), '99999999999999');

    if (!isKey(i, gCom)) {
        //阻断错误拦截一个错误
        /* 
        try 执行  catch 错误
        throw 抛出
        throw Error 抛出一个错误，继续执行后面逻辑
        */
        throw Error('这是一个错误阻断')
    }
    app.component(i, gCom[i])
}
app.use(store).use(router).use(ElementPlus).mount('#app')
